# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgbase=plasma-desktop
pkgname=(plasma-desktop knetattach)
pkgver=5.14.0
pkgrel=1
pkgdesc='KDE Plasma Desktop'
arch=(x86_64)
url='https://www.kde.org/workspaces/plasmadesktop/'
license=(LGPL)
source=("https://download.kde.org/stable/plasma/$pkgver/$pkgname-$pkgver.tar.xz"{,.sig})
depends=(polkit-kde-agent libxkbfile kmenuedit appstream-qt systemsettings ksysguard kpeople baloo)
makedepends=(extra-cmake-modules kdoctools boost xf86-input-evdev xf86-input-synaptics xf86-input-libinput xorg-server-devel
             libibus scim kdesignerplugin)
groups=(plasma)
sha256sums=('0069b4412956211e0d696fb240384351c8d8ad8f9d0b12721ec7a6bbd0693863'
            'SKIP')
validpgpkeys=('2D1D5B0588357787DE9EE225EC94D18F7F05997E'  # Jonathan Riddell <jr@jriddell.org>
              '0AAC775BB6437A8D9AF7A3ACFE0784117FBCE11D'  # Bhushan Shah <bshah@kde.org>
              'D07BD8662C56CB291B316EB2F5675605C74E02CF'  # David Edmundson <davidedmundson@kde.org>
              '1FA881591C26B276D7A5518EEAAF29B42A678C20') # Marco Martin <notmart@gmail.com>

prepare() {
  mkdir -p build
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCMAKE_INSTALL_LIBEXECDIR=lib \
    -DBUILD_TESTING=OFF
  make
}

package_plasma-desktop() {
  depends+=(knetattach)
  optdepends=('plasma-nm: Network manager applet'
              'powerdevil: power management'
              'ibus: kimpanel IBUS support'
              'scim: kimpanel SCIM support'
              'discover: manage applications installation from the launcher')

  cd build
  make DESTDIR="$pkgdir" install

# Split knetattach
  rm "$pkgdir"/usr/{bin/knetattach,share/applications/org.kde.knetattach.desktop}
}

package_knetattach() {
  pkgdesc='Wizard which makes it easier to integrate network resources with the Plasma Desktop'
  depends=(kdelibs4support)

  cd build/knetattach
  make DESTDIR="$pkgdir" install
}
